﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common
{
    public static class AppSetting
    {
        /// <summary>
        /// 上传文件夹
        /// </summary>
        public static string UploadRoute
        {
            get
            {
                var config = ConfigHelper.Configuration["UploadRoute"];
                if (!config.IsNullOrWhiteSpace())
                {
                    return config;
                }
                var dateNow = DateTime.Now;
                return $"upload/{dateNow.Year}/{dateNow.Month}";
            }
        }

        /// <summary>
        /// 编辑器上传路径
        /// </summary>
        public static string UploadCKEDITOR
        {
            get
            {
                var config = ConfigHelper.Configuration["UploadUploadCKEDITOR"];
                if (!config.IsNullOrWhiteSpace())
                {
                    return config;
                }
                var dateNow = DateTime.Now;
                return "UploadCKEDITOR";
            }
        }

        /// <summary>
        /// 默认密码
        /// </summary>
        public static string DefaultPassword
        {
            get
            {
                var config = ConfigHelper.Configuration["DefaultPassword"];
                if (!config.IsNullOrWhiteSpace())
                {
                    return config;
                }
                return "123456";
            }
        }

        /// <summary>
        /// 网站过期验证接口地址
        /// </summary>
        public static string ApiUrl
        {
            get
            {
                var config = ConfigHelper.Configuration["WebExpireValid:ApiUrl"];
                if (!config.IsNullOrWhiteSpace())
                {
                    return config;
                }
                return "";
            }
        }

        /// <summary>
        /// 网站对应的验证邮箱地址
        /// </summary>
        public static string ValidEmail
        {
            get
            {
                var config = ConfigHelper.Configuration["WebExpireValid:ValidEmail"];
                if (!config.IsNullOrWhiteSpace())
                {
                    return config;
                }
                return "";
            }
        }

        /// <summary>
        /// 是否需要验证
        /// </summary>
        public static bool IsNeedValid
        {
            get
            {
                return ConfigHelper.Configuration["WebExpireValid:IsNeedValid"].ToBoolean(true);
            }
        }

        /// <summary>
        /// 最大上传文件大小(默认为1MB)单位（MB）
        /// </summary>
        public static int MaxFile
        {
            get
            {
                var MaxFile = ConfigHelper.Configuration["MaxFile"].ToInt32(1);
                if (MaxFile <= 0)
                {
                    return 1;
                }
                return MaxFile;
            }
        }

    }
}
